package cn.qingyun.gis.modules.scenes.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.init.system.base.controller.BasicController;
import cn.qingyun.gis.modules.scenes.entity.UniAddrRegion;
import cn.qingyun.gis.modules.scenes.request.SubBoundaryRequest;
import cn.qingyun.gis.modules.scenes.service.UniAddrRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;


@Api(tags = "业务区划")
@RequestMapping("/app/region")
@RestController
@Slf4j
public class UniAddrRegionController extends BasicController<UniAddrRegion, UniAddrRegionService> {

    @Resource
    private UniAddrRegionService uniAddrRegionService;

    @ApiOperation("获取用户权限下地区数据")
    @GetMapping("/regionData")
    public Result<?> getRegionList() {
        return Result.okData(uniAddrRegionService.getRegionList());
    }

    @ApiOperation("获取区域边界")
    @GetMapping("/boundary")
    public Result<?> getBoundary(@RequestParam("code") @NotEmpty String code) {
        return Result.okData(uniAddrRegionService.selectRegionBoundary(code));
    }

    @ApiOperation("获取区域下的子边界列表")
    @PostMapping("/sub/boundary")
    public Result<?> getSubBoundary(@RequestBody SubBoundaryRequest request) {
        return Result.okData(uniAddrRegionService.selectRegionBoundaryList(request));
    }
}
